<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    request.setAttribute("path",path);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <%@ include file="/common/pre/header.jsp" %>
    <title>易买网</title>
</head>
<body>
<!--Begin Login Begin-->
<div class="log_bg">
    <div class="top">
        <div class="logo"><a href="${ctx}/Home?action=index"><img src="${ctx}/statics/images/logo.png"/></a></div>
    </div>
    <div class="regist">
        <div class="log_img"><img src="${ctx}/statics/images/l_img.png" width="611" height="425"/></div>
        <div class="reg_c">
            <form action="${path}/userAddServlet" method="post" id="myform" >
                <table border="0" style="width:420px; font-size:14px; margin-top:20px;" cellspacing="0" cellpadding="0">
                    <tr height="50" valign="top">
                        <td width="95">&nbsp;</td>
                        <td>
                            <P>${msg}</P>
                            <span class="fl" style="font-size:24px;">注册</span>
                            <span class="fr">已有商城账号，<a href="login.jsp" style="color:#ff4e00;">我要登录</a></span>
                        </td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;用户名 &nbsp;</td>
                        <td><input type="text" value="" id="username" name="loginname" class="l_user"/>
                            <input type="hidden" name="submitFormId" value="${submitFormId}"/>
                        </td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;密码 &nbsp;</td>
                        <td><input type="password" id="yuan" value="" name="Pwd" class="l_pwd" /></td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;确认密码 &nbsp;</td>
                        <td><input type="password" id="queren" value="" class="l_pwd" /></td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;性别 &nbsp;</td>
                        <td>
                            <input type="radio" name="sex" value="1" checked="checked">&nbsp;男&nbsp;&nbsp;
                            <input type="radio" name="sex" value="0">&nbsp;女
                        </td>
                    </tr>
                    <tr height="50">
                        <td align="right">&nbsp;身份证号 &nbsp;</td>
                        <td><input id="identityCode" type="text" value="" name="identityCode" class="l_user"/></td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;邮箱 &nbsp;</td>
                        <td><input type="text" value="" id="Email" name="Email" class="l_email" /></td>
                    </tr>
                    <tr height="50">
                        <td align="right"><font color="#ff4e00">*</font>&nbsp;手机 &nbsp;</td>
                        <td><input type="text" value="" id="Phone" name="Phone" class="l_tel" /></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td style="font-size:12px; padding-top:20px;">
                	<span style="font-family:'宋体';" class="fl">
                    	<label class="r_rad"><input type="checkbox" /></label><label class="r_txt">我已阅读并接受《用户协议》</label>
                    </span>
                        </td>
                    </tr>
<%--                    var sex = $("input[name='sex']:checked").val();--%>
<%--                    window.location="${path}/usersaddServlet?sex="+sex;--%>
                    <tr height="60">
                        <td>&nbsp;</td>
                        <td><input type="button" value="立即注册"class="log_btn" onclick="cheyanzheng()"  /></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<!--End Login End-->
<!--Begin Footer Begin-->
<div class="btmbg">
    <div class="btm">
        备案/许可证编号：蜀ICP备12009302号-1-www.dingguagua.com Copyright © 2015-2018 尤洪商城网 All Rights Reserved. 复制必究 , Technical
        Support: Dgg Group <br/>
        <img src="${ctx}/statics/images/b_1.gif" width="98" height="33"/><img src="${ctx}/statics/images/b_2.gif"  width="98" height="33"/><img
            src="${ctx}/statics/images/b_3.gif" width="98" height="33"/><img src="${ctx}/statics/images/b_4.gif"   width="98" height="33"/><img
            src="${ctx}/statics/images/b_5.gif" width="98" height="33"/><img src="${ctx}/statics/images/b_6.gif"   width="98" height="33"/>
    </div>
</div>
<!--End Footer End -->
</body>
<!--[if IE 6]>
<script src="//letskillie6.googlecode.com/svn/trunk/2/zh_CN.js"></script>
<![endif]-->

<script>
    // 验证密码
    function yanzpwd() {
        let pwd = document.getElementById("yuan").value;
        if (pwd==null || pwd.trim()==""){
            return false;
        }else {
            return true;
        }
    }

    // 确认密码
    function checkPwd() {
        var pass= document.getElementById("yuan").value;
        var queren = document.getElementById("queren").value;
        if(pass==queren){
            return true;
        }else{
            return false;
        }
    }

    // 验证用户名
    function checkUser() {
        let user = document.getElementById("username").value;
        if (user==null || user.trim()==""){
            return false;
        }else {
            return true;
        }
    }

    // 验证邮箱
    function checkEmail() {
        let email = document.getElementById("Email").value;
        if(email.indexOf("@")!=-1){
            return true;
        }else{
            return false;
        }
    }

    //验证手机号
    function checkPhone() {
        var userPhone= document.getElementById("Phone").value;
        var reg =/^[0-9]{11}$/;
        if(reg.test(userPhone)){
            return true;
        }else{
            return false;
        }
    }
    
    // 验证身份证
    function checkidentityCode() {
        let tity = document.getElementById("identityCode").value;
        if(tity!=null && tity.length==18){
            return true;
        }else {
            return false;
        }
    }

    // 提交表单
    function cheyanzheng() {
        if (!checkUser()){
            showMessage("用户名不符合规则");
            return false;
        }
        if (!yanzpwd()){
            showMessage("密码不符合规则");
            return false;
        }
        if (!checkPwd()){
            showMessage("密码两次不一致");
            return false;
        }
        if (!checkidentityCode()){
            showMessage("身份证号格式不正确");
            return false;
        }
        if(!checkEmail()){
            showMessage("邮箱不符合规则");
            return false;
        }
        if(!checkPhone()){
            showMessage("手机号不符合规则");
            return false;
        }
        //提交表单
        var myform=document.getElementById("myform");
        myform.submit();
    }

</script>

</html>
